var license = new Vue({
    el: "#license",
    data() {
        return {
            msg: null,
            applyData: {
                applyCode: null,
                authorizeCode: null,
            },
            rules: {
                authorizeCode: [
                    {required: true, message: '请填写授权码!', trigger: 'blur'}
                ]
            }

        };
    },
    created() {
        this.getApplyCode();
        this.msg = "[[${msg}]]";
        // alert(msg)
    },
    mounted() {
    },
    computed: {
    },
    methods: {
        getApplyCode() {
          $.ajax({
              url: '/getApplyCode',
              dataType: "json",
              type: "GET",
              success: res => {
                  this.applyData.applyCode = res.license;
              },
              error: err => {
                  console.log(err)
              }
          })
        },

        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    window.location.href = "/checkLicense?authorizeCode=" + this.applyData.authorizeCode
                    //
                    // $.ajax({
                    //     url: '/checkLicense',
                    //     dataType: "json",
                    //     data: {
                    //         authorizeCode: this.applyData.authorizeCode,
                    //     },
                    //     type: "post",
                    //     success: res => {
                    //         if(res.success) {
                    //             alert("授权成功")
                    //             this.applyData.authorizeCode = null;
                    //         } else {
                    //             alert("授权失败")
                    //
                    //         }
                    //
                    //     },
                    //     error: err => {
                    //         console.log(err)
                    //     }
                    // })
                }
            })


        }

    },
});